package com.chuhe.common.domain.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.chuhe.common.domain.enums.UserContactApplyStatusEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.io.Serializable;

/**
 * <p>
 * 联系人申请
 * </p>
 *
 * @author 张楚河
 * @since 2025-05-16
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("user_contact_apply")
public class UserContactApply implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 自增ID
     */
    @TableId(value = "apply_id", type = IdType.AUTO)
    private Integer applyId;

    /**
     * 申请人id
     */
    @TableField("apply_user_id")
    private String applyUserId;

    /**
     * 接收人ID
     */
    @TableField("receive_user_id")
    private String receiveUserId;

    /**
     * 联系人类型 0:好友 1:群组
     */
    @TableField("contact_type")
    private Integer contactType;

    /**
     * 联系人群组ID
     */
    @TableField("contact_id")
    private String contactId;

    /**
     * 最后申请时间
     */
    @TableField("last_apply_time")
//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
//    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Long lastApplyTime;

    /**
     * 状态0:待处理 1:已同意  2:已拒绝 3:已拉黑
     */
    @TableField("status")
    private Integer status;

    /**
     * 申请信息
     */
    @TableField("apply_info")
    private String applyInfo;

    private String statusName;

    public String getStatusName() {
        UserContactApplyStatusEnum statusEnum = UserContactApplyStatusEnum.getByStatus(status);
        return statusEnum == null ? null : statusEnum.getDesc();
    }
}